<<<<<<< HEAD
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Callback extends CI_Controller {
	
	function __construct(){
		parent::__construct();
	}
	
	function index(){
		//$this->load->model('User_model', 'user');
	}
	
	//授权安全回调认证
	function page_Accredit_service(){
		$result = $_REQUEST[result];
		$sign = $_REQUEST[sign];
		if(isset($result) && $result !='' && isset($sign) && $sign !=''){
			$content = "{DATE=".date('Y-m-d h:m:s',time())."|METHOD=page_Accredit_service|content=".$result."}\r\n";
	    file_put_contents(TRUSTEESHIP_LOG, $content,FILE_APPEND);
			$xml = simplexml_load_string($result);//结果解析
			if($xml->code == "CSD000"){
				$local_sign = Md5($result."~|~".KEY);
				if($local_sign == $sign){
					$this->load->model('User_model', 'user');
					//完成实名安全认证
					$setArr['real_status'] = 1;
					$this->user->update($setArr, array('user_id' => $xml->user_id));
				}
			}
		}
	}
	//充值回调
	function page_Recharge_service(){
		$MemberID		=	$_REQUEST['MemberID'];//商户号
		$TerminalID	 	=	$_REQUEST['TerminalID'];//商户终端号
		$TransID 		=	$_REQUEST['TransID'];//流水号
		$Result			=	$_REQUEST['Result'];//支付结果
		$ResultDesc		=	$_REQUEST['ResultDesc'];//支付结果描述
		$FactMoney		=	$_REQUEST['FactMoney'];//实际成功金额
		$AdditionalInfo	=	$_REQUEST['AdditionalInfo'];//订单附加消息
		$SuccTime		=	$_REQUEST['SuccTime'];//支付完成时间
		$Md5Sign		=	$_REQUEST['Md5Sign'];//md5签名
		$Md5key 		= 	KEY;
		$MARK 			= 	"~|~";
		$xml = 'MemberID='.$MemberID.$MARK.'TerminalID='.$TerminalID.$MARK.'TransID='.$TransID.$MARK.'Result='.$Result.$MARK.'ResultDesc='.$ResultDesc.$MARK.'FactMoney='.$FactMoney.$MARK.'AdditionalInfo='.$AdditionalInfo.$MARK.'SuccTime='.$SuccTime.$MARK.'Md5Sign='.$Md5key;
		//MD5签名格式
		$WaitSign=md5($xml);
		if ($MemberID == MERCHANT_ID && $TerminalID == TERMINAL_ID &&  $Md5Sign == $WaitSign) {
			//校验通过开始处理订单		
			//处理想处理的事情，验证通过，根据提交的参数判断支付结果
			echo ("ok");
			$content = "{DATE=".date('Y-m-d h:m:s',time())."|METHOD=page_Recharge_service|content=".$xml."}\r\n";
	    	file_put_contents(TRUSTEESHIP_LOG, $content,FILE_APPEND);
			
			$this->load->model('Accountrecharge_model', 'recharge');
			$ret = $this->recharge->onreturn(array("trade_no"=>$TransID,"returnxml"=>$xml,));
			
		} else {
			echo("Md5CheckFail'");//MD5校验失败
		   //处理想处理的事情
		} 
	
	}

	//丰付充值回调
	function page_Recharge_service_f(){
		var_dump($_REQUEST);exit;
		$requestId		=	$_REQUEST['requestId'];//请求流水号
		$payId		 	=	$_REQUEST['payId'];//交易流水号
		$fiscalDate		=	$_REQUEST['fiscalDate'];//会计日期，格式yyyyMMdd
		$description	=	$_REQUEST['description'];//辅助信息
		$resultSignature=	$_REQUEST['resultSignature'];//数字签名
		$payType		=	$_REQUEST['payType'];//支付类型
		$bankcode		=	$_REQUEST['bankcode'];//银行代码
		$totalPrice		=	$_REQUEST['totalPrice'];//订单金额
		$tradeAmount	=	$_REQUEST['tradeAmount'];//订单实际支付金额
		$tradeFee 		= 	$_REQUEST['tradeFee'];//手续费
		$status			= 	$_REQUEST['status'];//交易状态
		$userIdIdentity	= 	$_REQUEST['userIdIdentity'];//第三方用户ID
		$Md5key 		= 	KEY;
		$MARK 			= 	"~|~";
		$xml = 'requestId='.$requestId.$MARK.'payId='.$payId.$MARK.'fiscalDate='.$fiscalDate.$MARK.'description='.$description.$MARK.'resultSignature='.$resultSignature.$MARK.'payType='.$payType.$MARK.'bankcode='.$bankcode.$MARK.'totalPrice='.$totalPrice.$MARK.'tradeAmount='.$tradeAmount.$MARK.'tradeFee='.$tradeFee.$MARK.'status='.$status.$MARK.'userIdIdentity='.$userIdIdentity.$MARK.'Md5Sign='.$Md5key;
		//MD5签名格式
		$WaitSign=md5($xml);
		if ($MemberID == MERCHANT_ID && $TerminalID == TERMINAL_ID &&  $Md5Sign == $WaitSign) {
			//校验通过开始处理订单		
			//处理想处理的事情，验证通过，根据提交的参数判断支付结果
			echo "success";
			$content = "{DATE=".date('Y-m-d h:m:s',time())."|METHOD=page_Recharge_service|content=".$xml."}\r\n";
	    	file_put_contents(TRUSTEESHIP_LOG, $content,FILE_APPEND);
			
			$this->load->model('Accountrecharge_model', 'recharge');
			$ret = $this->recharge->onreturn(array("trade_no"=>$TransID,"returnxml"=>$xml,));
			
		} else {
			echo("Md5CheckFail'");//MD5校验失败
		   //处理想处理的事情
		} 
	}
}
=======
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Callback extends CI_Controller {
    
	function __construct(){
		parent::__construct();
	}
	
	function index(){
		//$this->load->model('User_model', 'user');
	}
	
	//授权安全回调认证
	function page_Accredit_service(){
		$result = $_REQUEST[result];
		$sign = $_REQUEST[sign];
		if(isset($result) && $result !='' && isset($sign) && $sign !=''){
			$content = "{DATE=".date('Y-m-d h:m:s',time())."|METHOD=page_Accredit_service|content=".$result."}\r\n";
	    file_put_contents(TRUSTEESHIP_LOG, $content,FILE_APPEND);
			$xml = simplexml_load_string($result);//结果解析
			if($xml->code == "CSD000"){
					$local_sign = Md5($result."~|~".KEY);
					if($local_sign == $sign){
						$this->load->model('User_model', 'user');
						//完成实名安全认证
						$setArr['real_status'] = 1;
						$this->user->update($setArr, array('user_id' => $xml->user_id));
					}
			}
		}
	}
	//充值回调
	function page_Recharge_service(){
		$MemberID		=	$_REQUEST['MemberID'];//商户号
		$TerminalID	 	=	$_REQUEST['TerminalID'];//商户终端号
		$TransID 		=	$_REQUEST['TransID'];//流水号
		$Result			=	$_REQUEST['Result'];//支付结果
		$ResultDesc		=	$_REQUEST['ResultDesc'];//支付结果描述
		$FactMoney		=	$_REQUEST['FactMoney'];//实际成功金额
		$AdditionalInfo	=	$_REQUEST['AdditionalInfo'];//订单附加消息
		$SuccTime		=	$_REQUEST['SuccTime'];//支付完成时间
		$Md5Sign		=	$_REQUEST['Md5Sign'];//md5签名
		$Md5key 		= 	KEY;
		$MARK 			= 	"~|~";
		$xml = 'MemberID='.$MemberID.$MARK.'TerminalID='.$TerminalID.$MARK.'TransID='.$TransID.$MARK.'Result='.$Result.$MARK.'ResultDesc='.$ResultDesc.$MARK.'FactMoney='.$FactMoney.$MARK.'AdditionalInfo='.$AdditionalInfo.$MARK.'SuccTime='.$SuccTime.$MARK.'Md5Sign='.$Md5key;
		//MD5签名格式
		$WaitSign=md5($xml);
		if ($MemberID == MERCHANT_ID && $TerminalID == TERMINAL_ID &&  $Md5Sign == $WaitSign) {
			//校验通过开始处理订单		
			//处理想处理的事情，验证通过，根据提交的参数判断支付结果
			echo ("ok");
			$content = "{DATE=".date('Y-m-d h:m:s',time())."|METHOD=page_Recharge_service|content=".$xml."}\r\n";
	    	file_put_contents(TRUSTEESHIP_LOG, $content,FILE_APPEND);
			
			$this->load->model('Accountrecharge_model', 'recharge');
			$ret = $this->recharge->onreturn(array("trade_no"=>$TransID,"returnxml"=>$xml,));
			
		} else {
			echo("Md5CheckFail'");//MD5校验失败
		   //处理想处理的事情
		} 	
	}

	//丰付充值回调
	function page_Recharge_service_f(){
		$requestId		=	$_REQUEST['requestId'];//商户号
		$payId		 	=	$_REQUEST['payId'];//交易流水号
		$fiscalDate 	=	$_REQUEST['fiscalDate'];//会计日期
		$description	=	$_REQUEST['description'];//透传信息
		$resultSignature=	$_REQUEST['resultSignature'];//数字签名
		$payType		=	$_REQUEST['payType'];//支付类型
		$bankCode		=	$_REQUEST['bankCode'];//银行代码
		$totalPrice		=	$_REQUEST['totalPrice'];//订单金额
		$tradeAmount	=	$_REQUEST['tradeAmount'];//订单实际支付金额
		$tradeFee		=	$_REQUEST['tradeFee'];//丰付收取的手续费
		$status			=	$_REQUEST['status'];//交易状态
		$userIdIdentity	=	$_REQUEST['userIdIdentity'];//第三方用户ID，用于绑定银行卡
		$Md5key 		= 	KEY_F;
		$MARK 			= 	"~|~";
		$xml = 'requestId='.$requestId.$MARK.'payId='.$payId.$MARK.'fiscalDate='.$fiscalDate.$MARK.'description='.$description.$MARK.'resultSignature='.$resultSignature.$MARK.'payType='.$payType.$MARK.'bankCode='.$bankCode.$MARK.'totalPrice='.$totalPrice.$MARK.'tradeAmount='.$tradeAmount.$MARK.'tradeFee='.$tradeFee.$MARK.'status='.$status.$MARK.'userIdIdentity='.$userIdIdentity.$MARK.'Md5Sign='.$Md5key;
		//MD5签名格式
		$WaitSign=md5($xml);

		if ($status=2&&$requestId!=null&&$payId!=null&&$description==DESCRIPTION) {
			//校验通过开始处理订单		
			//处理想处理的事情，验证通过，根据提交的参数判断支付结果
			echo "success";
			$content = "{DATE=".date('Y-m-d h:m:s',time())."|METHOD=page_Recharge_service_f|content=".$xml."}\r\n";
	    	file_put_contents(TRUSTEESHIP_LOG, $content,FILE_APPEND);
			
			$this->load->model('Accountrecharge_model', 'recharge');
			$ret = $this->recharge->onreturn(array("trade_no"=>$requestId,"returnxml"=>$xml,));
			
		} else {
			echo("Md5CheckFail'");//MD5校验失败
		   //处理想处理的事情
		} 	
	}
}
>>>>>>> d47623b610d79a4eeb489500830c00d70933f414
